<?php
class HttpStatus {
    /*
      HTTPClientError
      400 - HTTPBadRequest
      401 - HTTPUnauthorized
      402 - HTTPPaymentRequired
      403 - HTTPForbidden
      404 - HTTPNotFound
      405 - HTTPMethodNotAllowed
      406 - HTTPNotAcceptable
      407 - HTTPProxyAuthenticationRequired
      408 - HTTPRequestTimeout
      409 - HTTPConfict
      410 - HTTPGone
      411 - HTTPLengthRequired
      412 - HTTPPreconditionFailed
      413 - HTTPRequestEntityTooLarge
      414 - HTTPRequestURITooLong
      415 - HTTPUnsupportedMediaType
      416 - HTTPRequestRangeNotSatisfiable
      417 - HTTPExpectationFailed
      HTTPServerError
      500 - HTTPInternalServerError
      501 - HTTPNotImplemented
      502 - HTTPBadGateway
      503 - HTTPServiceUnavailable
      504 - HTTPGatewayTimeout
      505 - HTTPVersionNotSupported
     */

    public $category = 'system';

    public static function code($code = 404, $error = '') {
        Lang::setCategory('system');
        switch ($code) {
            // client error
            case 400: $message = Lang::t('400');
                break;
            case 401: $message = Lang::t('401');
                break;
            case 402: $message = Lang::t('402');
                break;
            case 403: $message = Lang::t('403');
                break;
            case 404: $message = Lang::t('404');
                break;
            case 405: $message = Lang::t('405');
                break;
            case 406: $message = Lang::t('406');
                break;
            case 407: $message = Lang::t('407');
                break;
            case 408: $message = Lang::t('408');
                break;
            case 409: $message = Lang::t('409');
                break;
            case 410: $message = Lang::t('410');
                break;
            case 411: $message = Lang::t('411');
                break;
            case 412: $message = Lang::t('412');
                break;
            case 413: $message = Lang::t('413');
                break;
            case 414: $message = Lang::t('414');
                break;
            case 415: $message = Lang::t('415');
                break;
            case 416: $message = Lang::t('416');
                break;
            case 417: $message = Lang::t('417');
                break;

            // server error
            case 500: $message = Lang::t('500');
                break;
            case 501: $message = Lang::t('501');
                break;
            case 502: $message = Lang::t('502');
                break;
            case 503: $message = Lang::t('503');
                break;
            case 504: $message = Lang::t('504');
                break;
            case 505: $message = Lang::t('505');
                break;

            default:
            case 404: $message = Lang::t('404');
                break;
        }//end switch

        throw new CHttpException($code, $message);
    }

}//end class
